import React, {Component, PropTypes} from 'react';
import SliderBar from '../layout/sliderBar';
import Header from '../layout/header';
import Styles from './common.less';
import { Row, Col } from 'antd';
import { connect } from 'dva';

class Page extends Component {
  constructor(props) {
    super(props)
  }

  componentDidMount() {
    this.props.dispatch({ type: 'indexPage/fetchBalance' });
    this.props.dispatch({ type: 'indexPage/fetchAdvert' });
    this.props.dispatch({ type: 'indexPage/fetchAgent' });
    this.props.dispatch({ type: 'indexPage/getAccountInfo' });
  }

  render() {
    return (
      <div className={Styles.page}>
        <SliderBar />
        <div className={Styles.content}>
          <Header {...this.props}/>
          <div className={Styles.main}>{this.props.children}</div>
        </div>
      </div>
    );
  }
};

Page.propTypes = {
  children: PropTypes.element
};

export default connect((state) => {
  const { bindList, account, permissions } = state.indexPage;
  return {
    account,
    bindList,
    permissions
  }
})(Page)